import Vue from 'vue'
import Router from 'vue-router'
import adminRoute from './admin'

let routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/index.vue'),
    redirect: '/index',
    children: [{
      path: 'index',
      name: 'home.index',
      component: () => import('@/components/home/index.vue')
    }]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/components/login/Login.vue'),
  },
  {
    path: '/excel',
    name: 'excel',
    component: () => import('@/views/admin/excel/List'),
  },
  {
    path: '/grid',
    name: 'grid',
    component: () => import('@/views/Grid'),
  },
  {
    path: '/render',
    name: 'render',
    component: () => import('@/views/RenderDemo'),
  },
]

routes = [...routes, ...adminRoute]

Vue.use(Router)

const router = new Router({ routes })

// 全局前置守卫
router.beforeEach((to, from, next) => {
  next()
})

export default router
